package testApplets;

import processing.core.PApplet;
import simpleGeom.Box3D;
import simpleGeom.Mesh;
import simpleGeom.Plane;
import simpleGeom.Vec3D;

public class FinalSectionApplet extends PApplet{
	public String folderPath="/Users/caad/Desktop/Grotto - First Half V/03_scaled/";
public void setup(){
	float y1=2600;
	float y2=2601;
	clip(folderPath+"layer6part0date7_1_15.obj",y1,y2);
	/*clip(folderPath+"1mm_v7_0_3_step_1.objcones.obj",y1,y2);
	clip(folderPath+"1mm_v7_0_2_step_1.objcones.obj",y1,y2);
	clip(folderPath+"1mm_v7_0_1_step_1.objcones.obj",y1,y2);
	clip(folderPath+"1mm_v7_0_0_step_1.objcones.obj",y1,y2);*/
}
public void clip(String path, float y1,float y2){
	Mesh meshInput= new Mesh(path);
	
	Box3D mBds =meshInput.getBounds();
	
	//float y2=mBds.y2;
	//float y2=y1+2f;//0.4f
	println(meshInput.getBounds());
	println("meshInput");
	meshInput.triangulate();
	println("triangulated");
	meshInput.construct();
	println("constructed");
	Plane plane=new Plane(new Vec3D(0,y1,0),new Vec3D(0,1,0));
	meshInput.trimMesh(plane);
	println("trimmed 1");
	meshInput.triangulate();
	 plane=new Plane(new Vec3D(0,y2,0),new Vec3D(0,-1,0));
	meshInput.trimMesh(plane);
	meshInput.construct();
	println("trimmed 2");
	meshInput.triangulate();
	meshInput.saveMesh(path+"_"+y1+"_"+y2+".obj",false);
	println("saved");
	
}
}
